import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import userStore from './user'
import vuexAlong from 'vuex-along'
import { getSlideItems } from "@/api/layout";


const store = new Vuex.Store({
    state: {
        slideItems: [],
        isAble: true,
        tableData: [],
        selectLevel: [],
        btn_permission: [],
        routerName: [],
    },
    mutations: {
        setRouterName(state, arr) {
            state.routerName = arr
        },
    },
    actions: {
        getSlideName(context) {
            return new Promise((resolve, reject) => {
                let temp = []
                getSlideItems().then(res => {
                    res.data.data.forEach((item, index, arr) => {
                        temp.push(item.ps_name)
                        if (index === arr.length - 1) {
                            console.log("vuex--", temp);

                            context.commit("setRouterName", temp)
                            resolve(temp)
                        }
                    });
                })
            })
        }
    },
    getters: {

    },
    modules: {
        userStore
    },
    // plugins: [vuexAlong({
    //     // list:[RouterData]
    // })]
})

export default store